/**
 * Copyright &copy; 2012-2016 <a href="https://istep.lczyfz.com">Istep</a> All rights reserved.
 */
package com.lczyfz.istep.modules.resource.service;

import java.util.List;

import com.lczyfz.istep.common.constants.DeleteFlag;
import com.lczyfz.istep.modules.resource.entity.ResourcePaper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lczyfz.istep.common.persistence.Page;
import com.lczyfz.istep.common.service.CrudService;
import com.lczyfz.istep.modules.resource.entity.ResourceCtfSet;
import com.lczyfz.istep.modules.resource.dao.ResourceCtfSetDao;

/**
 * CTF题目集管理Service
 * @author dh
 * @version 2017-01-16
 */
@Service
@Transactional(readOnly = true)
public class ResourceCtfSetService extends CrudService<ResourceCtfSetDao, ResourceCtfSet> {

	@Autowired
	ResourceCtfSetDao resourceCtfSetDao;

	public ResourceCtfSet get(String id) {
		return super.get(id);
	}
	
	public List<ResourceCtfSet> findList(ResourceCtfSet resourceCtfSet) {
		return super.findList(resourceCtfSet);
	}
	
	public Page<ResourceCtfSet> findPage(Page<ResourceCtfSet> page, ResourceCtfSet resourceCtfSet) {
		return super.findPage(page, resourceCtfSet);
	}
	
	@Transactional(readOnly = false)
	public void save(ResourceCtfSet resourceCtfSet) {
		super.save(resourceCtfSet);
	}
//	fd
	@Transactional(readOnly = false)
	public void delete(ResourceCtfSet resourceCtfSet) {
		super.delete(resourceCtfSet);
	}

	//添加下发-根据培训方案id获取CTF题目集
	public List<ResourceCtfSet> findCtfSetById(String trainProgramId){
		if( trainProgramId == null || trainProgramId.equals("") ){
			return resourceCtfSetDao.findList(new ResourceCtfSet());
		}else {
			return resourceCtfSetDao.findCtfSetById(trainProgramId, DeleteFlag.deleteFlag);
		}
	}

	/**
	 *根据课程体系id查询CTF题目集列表
	 * @param page
	 * @param resourceCtfSet
	 * @return
	 */
	public Page<ResourceCtfSet> findPageByTrainprogramId(Page<ResourceCtfSet> page, ResourceCtfSet resourceCtfSet) {
		resourceCtfSet.setPage(page);
		page.setList(dao.findPageByTrainprogramId(resourceCtfSet));
		return page;
	}



	//我的CTF-CTF题目集列表展示
	public Page<ResourceCtfSet> stuCtfSetList(Page<ResourceCtfSet> page, ResourceCtfSet resourceCtfSet) {
		resourceCtfSet.setPage(page);
		page.setList(resourceCtfSetDao.stuCtfSetList(resourceCtfSet));
		return page;
	}
    //
	public ResourceCtfSet findCtfSetByCtfSetName(ResourceCtfSet resourceCtfSet) {

		return dao.findCtfSetByCtfSetName(resourceCtfSet);
	}

//	//根据属性来查询 ctf题目
//	public List<ResourceCtfSet> findListByAttribute(String attribute) {
//
//		return dao.findListByAttribute(attribute);
//	}

	//我的学习任务-获取CTF题目集名称
	public List<ResourceCtfSet> stuLearnCtfSet(String distributeId, String userId){
		return resourceCtfSetDao.stuLearnCtfSet(distributeId, userId, DeleteFlag.deleteFlag);
	}
}